<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>波尔共振实验</title>
		<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
		<script src="https://code.highcharts.com/highcharts.js"></script>
	</head>
	<body>
		<button onclick="show1()">第1列数据</button>
		<button onclick="show2()">第2列数据</button>
		<button onclick="show3()">汇制表格</button><br />
		<div id="container" style="width: 95vw; height: 80vh; margin: 0 auto"></div>
		<script src="./data.js"></script>
		<script>
			const keep = (x, len) => Math.round(x * 10 ** len) / 10 ** len;

			const s1 = Array(0.5 * 振幅角度.length)
				.fill(0)
				.map((_, k) => 振幅角度[k] / 振幅角度[k + 5])
				.map((v) => keep(v, 3));

			const s2 = s1.map((v) => Math.log(v)).map((v) => keep(v, 保留小数位));

			const s3 = s2.reduce((pre, cur) => pre + cur, 0) / 5;

			const s4 = 强迫力矩周期
				.map((v) => (0.1 * 十倍周期) / v)
				.map((v) => keep(v, 保留小数位));

			const title = {
				text: "绘制幅（相）频特性曲线",
			};

			const series = [
				{
					name: "幅频特性曲线",
					data: [],
				},
				{
					name: "相频特性曲线",
					data: [],
				},
			];

			function show1() {
				console.log("比值：");
				console.table(s1);
				console.log("比值对数：");
				console.table(s2);
				console.log("平均值 = " + s3);
				console.log("阻尼系数 = " + (2 * s3) / 十倍周期);
			}

			function show2() {
				console.log("周期比值：");
				console.table(s4);
			}

			function show3() {
				series[0].data = 受迫振幅;
				series[1].data = 相位差;

				$("#container").highcharts({
					title,
					series,
					xAxis: {
						categories: s4.reverse(),
					},
				});
			}
		</script>
	</body>
</html>
